using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/****************************************************
// 功能：防御塔表现层
// | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
// | Copyright (c) 2021-2025 聊来 All rights reserved.
// | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">聊来</a> )
// | @Author: 贯彻己道的云 <18970881148@qq.com>
// | DateTime: 2025/4/10 10:33:36
*****************************************************/

public class TowerView : MainViewUnit
{
    public Tower tower;
    
    public override void Init(LogicUnit logicUnit) {
        base.Init(logicUnit);

        tower = logicUnit as Tower;
    }
    
    public override void PlayAni(string aniName) { }

    public void DestroyTower()
    {
        var transMapRoot = GameObject.FindGameObjectWithTag(Constants.MAP_ROOT).transform;
        var mapRoot = transMapRoot.GetComponent<MapRoot>();
        var self = BattleController.Instance.GetSelfHero();

        switch(tower.towerId) {
            case 1001: 
                BattleController.Instance.PlayBattleFieldAudio(self.IsTeam(TeamEnum.Blue) ? "selfTowerDestroy" : "destroyEnemyTower"); 
                mapRoot.DestroyBlueTower();
            break;
            case 1002: 
                mapRoot.DestroyBlueCrystal();
            break;
            case 2001:
                BattleController.Instance.PlayBattleFieldAudio(self.IsTeam(TeamEnum.Blue) ? "destroyEnemyTower" : "selfTowerDestroy"); 
                mapRoot.DestroyRedTower();
            break;
            case 2002: 
                mapRoot.DestroyRedCrystal();
            break;
            default: break;
        }
        
        RemoveItemInfo();
        Destroy(gameObject, 1f);
    }
}
